﻿using MovingChameLibrary.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace MovingChameLibrary.DataManager
{
    public class TourGroupCollectionData
    {
        private static TourGroupCollectionData current;
        public static TourGroupCollectionData Current
        {
            get
            {
                if (current == null)
                    current = new TourGroupCollectionData();
                return current;
            }
        }

        private ObservableCollection<TourGroup> _personalGroups;
        public ObservableCollection<TourGroup> PersonalGroups
        {
            get
            {
                _personalGroups = new ObservableCollection<TourGroup>();
                _personalGroups.Add(TourGroupData.Current.FavouriteGroup);
                _personalGroups.Add(TourGroupData.Current.PreviousGroup);
                _personalGroups.Add(TourGroupData.Current.CreatingGroup);
                _personalGroups.Add(TourGroupData.Current.SharedGroup);
                _personalGroups.Add(TourGroupData.Current.ConfirmedGroup);
                return this._personalGroups;
            }
        }

        private ObservableCollection<TourGroup> _officialGroups;
        public ObservableCollection<TourGroup> OfficialGroups
        {
            get
            {
                _officialGroups = new ObservableCollection<TourGroup>();
                _officialGroups.Add(TourGroupData.Current.NewestGroup);
                _officialGroups.Add(TourGroupData.Current.HottestGroup);
                _officialGroups.Add(TourGroupData.Current.CheapestGroup);
                _officialGroups.Add(TourGroupData.Current.SuggestGroup);
                _officialGroups.Add(TourGroupData.Current.SuitableGroup);
                return this._officialGroups;
            }
        }

        public static TourGroup GetItem(int uniqueId)
        {
            var matches = TourGroupCollectionData.Current.PersonalGroups.Where(item => (item as TourGroup).Id.Equals(uniqueId));
            if (matches.Count() == 1) return matches.First();

            return TourGroupData.Current.FriendGroup;
        }
    }
}